package pkev.xgrapher.component.models;

import pkev.xgrapher.Constants;
import pkev.xgrapher.common.entity.XFlowGraphics;

import java.awt.*;

public class Grid extends AbstractGrapherModel {

    @Override
    public void draw(XFlowGraphics g) {
        g.getG().setColor(new Color(41, 41, 41));

        g.drawLine(Constants.MIN_X, 0, Constants.MAX_X, 0);
        g.drawLine(0, Constants.MIN_Y, 0, Constants.MAX_Y);

        int h = 1;

        for (int i = 0; i < Constants.MAX_X; i += Constants.AXIS_DELTA) {
//            for (int j = Constants.MIN_X; j <= Constants.MAX_X;) {
//                g.drawLine(i, j, i, j + h);
//                j += 2;
//            }
            g.drawLine(i, Constants.MIN_Y, i, Constants.MAX_Y);
        }

        for (int i = 0; i > Constants.MIN_X; i -= Constants.AXIS_DELTA) {
//            for (int j = Constants.MIN_X; j <= Constants.MAX_X;) {
//                g.drawLine(i, j, i, j + h);
//                j += 2;
//            }
            g.drawLine(i, Constants.MIN_Y, i,  Constants.MAX_Y);
        }

        for (int i = 0; i < Constants.MAX_Y; i += Constants.AXIS_DELTA) {
//            for (int j = Constants.MIN_X; j <= Constants.MAX_X;) {
//                g.drawLine(j, i, j + h, i);
//                j += 2;
//            }
            g.drawLine(Constants.MIN_X, i, Constants.MAX_X, i);
        }

        for (int i = 0; i > Constants.MIN_Y; i -= Constants.AXIS_DELTA) {
//            for (int j = Constants.MIN_X; j <= Constants.MAX_X;) {
//                g.drawLine(j, i, j + h, i);
//                j += 2;
//            }
            g.drawLine(Constants.MIN_X, i, Constants.MAX_X, i);
        }
    }

    @Override
    public int getLayoutIndex() {
        return -2;
    }
}
